package com.china.produce.config.interceptor;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * @ClassName
 * @Author niujie
 * @Version
 * @Description
 * @CreateTime 2022/10/23
 */
@Configuration
public class InterceptorConfig implements WebMvcConfigurer {

    public static final String[] excludePathPatterns = {"/css/**", "/fronts/**", "/img/**", "/js/**", "/*.html",
            "/*.ico", "/themes/**", "/users/login", "/audio/factory/**"};

    @Autowired
    ExternalAccessInterceptor externalAccessInterceptor;

    @Autowired
    HeaderInterceptor headerInterceptor;

    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(headerInterceptor)
                .addPathPatterns("/users/userInfo")
                .excludePathPatterns(excludePathPatterns);

        registry.addInterceptor(externalAccessInterceptor)
                .addPathPatterns("/users/info")
                .excludePathPatterns(excludePathPatterns);
    }
}
